#include "CmdKernel.h"
#include "gui.h"
#include "world.h"
#include "Creature.h"

void CmdKernel::RunCommand(const char *cmd, GuiConsole *output)
{
    vector<string> args;
    split(args, cmd, ' ');

    if (args.size() == 0)
        return;

    if (args[0] ==  "cls") {
        output->clear();
    } else if (args[0] == "showhis") {
        output->showhistory();
    } else if (args[0] == "mob") {
        if (args.size() < 4) {
            output->printline("Usage: mob monsterid x y [dead/alive]");
            return;
        }

        Monster *m = Monster::New(atoi(args[1]));
        if (m == NULL)
            output->printline("monster type error!!");
        else
        {
            MapVisitor mv;
            if (!mv.put_monster(m, test::g_map, atoi(args[2]), atoi(args[3])))
            {
                output->printline("put monster failed!!");
                delete m;
            }
/*
        if (args.size() > 4) {
            if (args[4] != "alive")
                Monster *p = INST(World).getMonster(x, y);
                if (p) p->die();
*/
        }

    } else if (args[0] == "!mob") {
//        INST(World).clearMonster();
    }
}
